package saci.util.xml;

import java.util.HashMap;
import java.util.Iterator;

public class Node implements Iterable<Node>  {
	private HashMap<String, String> attributes;
	private String name;
	private boolean hasChild;
	private String content;
	
	protected Node() {
	}
	
	public Iterator<Node> iterator() {
		if (hasChild) {
			StringBuilder content = new StringBuilder();
			content.append(this.content);
	    	content.append("</");
	    	content.append(name);
	    	content.append(">");
			return new Parser(content.toString(), attributes).iterator();
		}
		return null;
	}

	public HashMap<String, String> getAttributes() {
		return attributes;
	}

	protected void setAttributes(HashMap<String, String> attributes) {
		this.attributes = attributes;
	}

	public boolean hasChild() {
		return hasChild;
	}

	protected void setHasChild(boolean hasChild) {
		this.hasChild = hasChild;
	}

	public String getContent() {
		return content;
	}

	protected void setContent(String content) {
		this.content = content;
	}

	public String getName() {
		return name;
	}

	protected void setName(String name) {
		this.name = name;
	}
	
}
